package pl.koziolekweb.szkola.EBFileTree;

// EB-FileTree/FileTree.java
 
import java.io.File;

public class FileTree {

    public static void main(String[] args) {
        File file = (args.length == 0) ?
              new File(System.getProperty("user.dir")).
                       getParentFile().getParentFile()
            : new File(args[0]);
        lista(file,"");
    }

    private static void lista(File dir, String skip) {

        // indentation
        System.out.print(skip);

        System.out.println("[" + dir.getName() + "]");
        skip = skip + "    ";
        File[] lis = dir.listFiles();
        for (int i = 0; i < lis.length; i++) {
            if (lis[i].isFile()) {
                System.out.print(skip);
                System.out.println(" " + lis[i].getName());
            }
        }
        for (int i = 0; i < lis.length; i++)
            if (lis[i].isDirectory())
                lista(lis[i],skip);
    }
}
